package mya.mes.mdc.weixin;

import mya.mes.mdc.share.api.MdcModule;
import mya.mes.mdc.share.vo.MdcOptions;

public class WxUploadManager {


    private static WxUploadManager _instance = new WxUploadManager();

    private WxMqttClient wxMqttClient = new WxMqttClient();
    private volatile boolean isInitialized = false;

    private WxUploadManager() {

    }

    public static WxUploadManager getInstance() {
        return _instance;
    }

    public synchronized void start() {
        if (!isInitialized) {
            MdcOptions mdcOptions = MdcModule.getInstance().getMdcOptions();
            if (mdcOptions.ALARM_SENT_TO_WEIXIN) {
                wxMqttClient.init(mdcOptions);
            }
            isInitialized = true;
        }

    }

    public void publish(String content) throws Exception {
        wxMqttClient.publish(content);
    }


    public void shutdown() throws Exception {
        wxMqttClient.shutdown();
    }

}
